const {
    getProvinces,
    getCitiesByProvince,
    getAreasByCity,
} = require("../controller/areaController");
const {
    getAllStudents,
    getStudentDetails,
    getStudentsByPage,
    addStudent,
    deleteStudent,
    updateStudent,
    getDashboardData,
} = require("../controller/studentController");
const { register, login } = require("../controller/userController");
const {
    getUserInfoByUserId,
    updateUserInfo,
    updateAvatar,
} = require("../controller/userInfoController");
const { tokenVerify } = require("../utils/tokenVerify");
const upload = require("../utils/uploadConfig");
const router = require("koa-router")();

// 路由只是表名到哪儿干什么，不需要表明怎么干
// 登陆注册接口
router.post("/register", register);
router.post("/login", login);

// 用户信息接口
router.get("/userInfo/:UserId", getUserInfoByUserId);
router.put("/userInfo/:UserId", updateUserInfo);
router.put("/userInfo/:UserId/avatar", upload.single("avatar"), updateAvatar);

// 地区信息接口
router.get("/area/provinces", getProvinces);
router.get("/area/:provinceCode/cities", getCitiesByProvince);
router.get("/area/:cityCode/areas", getAreasByCity);

// 学生信息接口
router.get("/studentsList", getAllStudents);
router.get("/students/:id", getStudentDetails);
router.get("/students", getStudentsByPage);
router.post("/students", addStudent);
router.delete("/students/:id", deleteStudent);
router.put("/students/:id", updateStudent);

router.get("/dashboard", getDashboardData);

module.exports = router;
